package com.cartoonrabbit.wxapp.utils;

import cn.hutool.core.util.RandomUtil;
import com.cartoonrabbit.consts.PreFixTypes;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 订单号工具类
 *
 * @author qy
 * @since 1.0
 */
public class PrimaryKeyUtils {


    /**
     * 获取订单编号
     * @return
     */
    public static String getOrderNo() {
        return RandomUtil.randomNumbers(10) + getNo();
    }

    /**
     * 获取退款单编号
     * @return
     */
    public static String getRefundNo() {
        return PreFixTypes.REFUND + getNo();
    }
    /**
     * 获取转账编号
     */
    public static String getTransferNo(){
        return RandomUtil.randomNumbers(10)+getNo();
    }

    /**
     * 购课编号
     */
    public static String getBuyCourseInfoNo(){
        return PreFixTypes.SHOPING_COURSE+ RandomUtil.randomString(50-PreFixTypes.SHOPING_COURSE.length());
    }


    /**
     * 获取余额明细编号
     */
    public static String getDetailNo(){
        return PreFixTypes.BALANCE+ RandomUtil.randomString(15-PreFixTypes.BALANCE.length());
    }

    /**
     * 获取评论编号
     */
    public static String getCommentNo(){
        return PreFixTypes.COMMENT+ RandomUtil.randomString(20-PreFixTypes.COMMENT.length());
    }

    /**
     * 获取提成信息编号
     */
    public static String getRoyaltiesId(){
        return PreFixTypes.ROYALTIES+ RandomUtil.randomString(20-PreFixTypes.ROYALTIES.length());
    }

    /**
     * 获取编号
     * @return
     */
    public static String getNo() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate = sdf.format(new Date());
        String result = "";
        Random random = new Random();
        for (int i = 0; i < 3; i++) {
            result += random.nextInt(10);
        }
        return newDate + result;
    }


}
